package com.qch;

import com.qch.bean.ConsumerComponet;
import com.qch.service.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @Author qch
 * @Date 2021/2/15
 */
public class XMLConsumerMain {
    public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("consumer.xml");
        HelloService service=classPathXmlApplicationContext.getBean(HelloService.class);
        while (true)
        {
            System.in.read();
            String jhh = service.sayHello("haha111",0);
            //利用future模式来获取值
            Future<Object>future=RpcContext.getContext().getFuture();
            System.out.println("结果"+jhh);
            System.out.println("future结果"+future.get());

        }
    }

}
